#ifndef CALIBRATION_H
#define CALIBRATION_H

#include <QWizard>

#include <QGridLayout>
#include <QCheckBox>
#include <QLabel>
#include <QLineEdit>
#include <QGroupBox>
#include <QRadioButton>
#include <QProgressBar>
#include <QPushButton>
#include <QSplashScreen>
#include "Control/config.h"

#define NUMBEROFBOTTLES 14

#define CALIBRATIONSAMPLES 5

//class QCheckBox;
//class QGroupBox;
//class QLabel;
//class QLineEdit;
//class QRadioButton;


class IntroCalPage : public QWizardPage
{
    Q_OBJECT

public:
    IntroCalPage(QWidget *parent = 0);

private:
    QLabel *label;
};
/** **************************************************************** */
class CalibrationPage : public QWizardPage
{
    Q_OBJECT

public:
    CalibrationPage(QWidget *parent = 0);
    QProgressBar *pBar;
    QGroupBox * btnGroup;
    QRadioButton* actBottlesBtn[NUMBEROFBOTTLES];
    QCheckBox* freezeLowerValueBox;
    QCheckBox* freezeUpperValueBox;
    QPushButton *calibrateBtn;
    QLineEdit *lowerValueEdit;
    QLineEdit *upperValueEdit;
    QLabel *averageLowerValueLabel;
    QLabel *averageUpperValueLabel;

    int calibrateBtnNumber;

    float lowerPressure;
    float upperPressure;

    float averageLowerValue;
    float averageUpperValue;

    bool calibrationRangeValid;

    int connectorNumberForCalibration;
    bool lowerCalibrationInProgress;
    bool upperCalibrationInProgress;
    bool lowerCalibrationDone;
    bool upperCalibrationDone;
    int calibrationCounter;
    float voltValueForConnector[NUMBEROFBOTTLES][CALIBRATIONSAMPLES];

    void setConfig(Config *conf);
    void setConnectorValue(int conNumber, float value);

private:
    QLabel *label;
    Config *config;


    void initializePage();
    void setProgressBarColor(float value);
    void checkIfCalibrationIsInProgress(float value);
    void resetCalibration();
    void checkIfCalibrationIsValid();

public slots:
    void changeActiveBottle(bool);
    void freezeLowerValue(bool checked);
    void freezeUpperValue(bool checked);
    void calibrateConnector();
};

/** **************************************************************** */
class Calibration : public QWizard
{
    Q_OBJECT
public:
    Calibration(QWidget *parent = 0);
    CalibrationPage *calPage;
    IntroCalPage *introPage;
    Config *config;



    void setConfig(Config *conf);
    void setConnectorValue(int conNumber, float value);
    void accept();
};
/** **************************************************************** */



#endif // WIZARDCALIBRATION_H
